﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using BEGDC.CC.BL.CCFlow.EV;
using BEGDC.CC.BL.Common.Query;
using BEGDC.CC.Entity;

namespace BEGDC.CC.Web.UserControls.EV
{
    /// <summary>
    /// Summary description for AssignApps.
    /// </summary>
    public class AssignApps : System.Web.UI.Page
    {
        protected System.Web.UI.WebControls.Button btnAssign;
        protected BEGDC.CC.Web.Control.UserSearchControl SearchStaff;
        protected System.Web.UI.WebControls.Label lblStaff;
        protected System.Web.UI.WebControls.Button ibtnClose;
        private string AppIDs
        {
            get
            {
                return ViewState["AppIDs"].ToString();
            }
            set
            {
                ViewState["AppIDs"] = value;
            }
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            // Put user code to initialize the page here
            if (!IsPostBack)
            {
                AppIDs = Request.QueryString["AppIDs"];

                this.btnAssign.Attributes["onclick"] = "javascript:OnAssign();";
                this.ibtnClose.Attributes["onclick"] = "javascript:OnClose();";
            }
        }

        #region Web Form Designer generated code
        override protected void OnInit(EventArgs e)
        {
            //
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            //
            InitializeComponent();
            base.OnInit(e);
        }

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.btnAssign.Click += new EventHandler(btnAssign_Click);
            this.Load += new System.EventHandler(this.Page_Load);

        }
        #endregion

        void btnAssign_Click(object sender, EventArgs e)
        {
            string[] appID;
            appID = AppIDs.Split(';');
            try
            {
                Hashtable hsTable = new Hashtable();
                Application app = null;
                IQuery queryService = BEGDC.Utility.Castle.AppContainer.Instance[BEGDC.CC.BL.Common.ServiceConst.QueryService] as IQuery;
                IEV evService = BEGDC.Utility.Castle.AppContainer.Instance[BEGDC.CC.BL.Common.ServiceConst.EVService] as IEV;
                for (int i = 0; i < appID.Length; i++)
                {
                    app = queryService.GetAppById(Convert.ToInt32(appID[i]));
                    hsTable.Add(app, null);
                }

                //evService.AssignEVRequest( hsTable, null );
            }
            catch
            {
            }
        }
    }
}
